﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//new
using DataRecv.models;
using System.Collections;

namespace DataRecv
{
    public partial class Form_Tongji : Form
    {
        public Form_Tongji()
        {
            InitializeComponent();
        }

        private void Form_Tongji_Load(object sender, EventArgs e)
        {
            LoadKKCount();
            LoadDJCount();
        }

        private void LoadKKCount()
        { 
            try
            {
                if (G.KKCount != null)
                {
                    dataGridView1.Rows.Clear();
                    foreach (KKTongJiParam device in G.KKCount)
                    {
                        if (device != null)
                        {
                            dataGridView1.Rows.Add(device.ip,
                                device.roadname,
                                device.fx,
                                device.h[0].ToString(),
                                device.h[1].ToString(),
                                device.h[2].ToString(),
                                device.h[3].ToString(),
                                device.h[4].ToString(),
                                device.h[5].ToString(),
                                device.h[6].ToString(),
                                device.h[7].ToString(),
                                device.h[8].ToString(),
                                device.h[9].ToString(),
                                device.h[10].ToString(),
                                device.h[11].ToString(),
                                device.h[12].ToString(),
                                device.h[13].ToString(),
                                device.h[14].ToString(),
                                device.h[15].ToString(),
                                device.h[16].ToString(),
                                device.h[17].ToString(),
                                device.h[18].ToString(),
                                device.h[19].ToString(),
                                device.h[20].ToString(),
                                device.h[21].ToString(),
                                device.h[22].ToString(),
                                device.h[23].ToString(),
                                device.h[24].ToString()
                                );
                        }
                    }
                }
            }
            catch { }
        }

        private void LoadDJCount()
        {
            try
            {
                if (G.DJCount != null)
                {
                    dataGridView2.Rows.Clear();
                    foreach (DJTongJiParam device in G.DJCount)
                    {
                        if (device != null)
                        {
                            dataGridView2.Rows.Add(device.ip,
                                device.roadname,
                                device.fx,
                                device.h[0].ToString(),
                                device.h[1].ToString(),
                                device.h[2].ToString(),
                                device.h[3].ToString(),
                                device.h[4].ToString(),
                                device.h[5].ToString(),
                                device.h[6].ToString(),
                                device.h[7].ToString(),
                                device.h[8].ToString(),
                                device.h[9].ToString(),
                                device.h[10].ToString(),
                                device.h[11].ToString(),
                                device.h[12].ToString(),
                                device.h[13].ToString(),
                                device.h[14].ToString(),
                                device.h[15].ToString(),
                                device.h[16].ToString(),
                                device.h[17].ToString(),
                                device.h[18].ToString(),
                                device.h[19].ToString(),
                                device.h[20].ToString(),
                                device.h[21].ToString(),
                                device.h[22].ToString(),
                                device.h[23].ToString(),
                                device.h[24].ToString()
                                );
                        }
                    }
                }
            }
            catch { }
        }

        private void toolStripMenuItem_kk_Click(object sender, EventArgs e)
        {
            LoadKKCount();
        }

        private void toolStripMenuItem_dj_Click(object sender, EventArgs e)
        {
            LoadDJCount();
        }
    }
}
